#include <p18cxxx.h>
#include <led_display.h>

#pragma code


unsigned int led_display_16 (unsigned short long maximum_range,unsigned short long vble_input_rng)
{
	unsigned int led_display_16_output = 0;

	if(vble_input_rng>=((maximum_range*16)>>4))
	{
	led_display_16_output = 0xFFFF;
	}
	else if(vble_input_rng>=((maximum_range*15)>>4))
	{
	led_display_16_output = 0x7FFF;
	}
	else if(vble_input_rng>=((maximum_range*14)>>4))
	{
	led_display_16_output = 0x3FFF;
	}
	else if(vble_input_rng>=((maximum_range*13)>>4))
	{
	led_display_16_output = 0x1FFF;
	}
	else if(vble_input_rng>=((maximum_range*12)>>4))
	{
	led_display_16_output = 0xFFF;
	}
	else if(vble_input_rng>=((maximum_range*11)>>4))
	{
	led_display_16_output = 0x7FF;
	}
	else if(vble_input_rng>=((maximum_range*10)>>4))
	{
	led_display_16_output = 0x3FF;
	}
	else if(vble_input_rng>=((maximum_range*9)>>4))
	{
	led_display_16_output = 0x1FF;
	}
	else if(vble_input_rng>=((maximum_range*8)>>4))
	{
	led_display_16_output = 0xFF;
	}
	else if(vble_input_rng>=((maximum_range*7)>>4))
	{
	led_display_16_output = 0x7F;
	}
	else if(vble_input_rng>=((maximum_range*6)>>4))
	{
	led_display_16_output = 0x3F;
	}
	else if(vble_input_rng>=((maximum_range*5)>>4))
	{
	led_display_16_output = 0x1F;
	}
	else if(vble_input_rng>=((maximum_range*4)>>4))
	{
	led_display_16_output = 0xF;
	}
	else if(vble_input_rng>=((maximum_range*3)>>4))
	{
	led_display_16_output = 0x7;
	}
	else if(vble_input_rng>=((maximum_range*2)>>4))
	{
	led_display_16_output = 0x3;
	}
	else if(vble_input_rng>=((maximum_range)>>4))
	{
	led_display_16_output = 0x1;
	}
	else
	{
	led_display_16_output = 0x0;
	}


return led_display_16_output;

}


